/*     */ package com.umeng.newxp.net;
/*     */ 
/*     */ import android.content.Context;
/*     */ import android.content.SharedPreferences;
/*     */ import android.content.SharedPreferences.Editor;
/*     */ import com.umeng.common.Log;
/*     */ import com.umeng.common.net.o;
/*     */ import com.umeng.common.net.p.a;
/*     */ import com.umeng.common.util.h;
/*     */ import com.umeng.newxp.controller.XpListenersCenter.ReportListener;
/*     */ import java.net.URLDecoder;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ 
/*     */ public class XpReportClient extends a
/*     */ {
/*  29 */   private static final String a = XpReportClient.class.getName();
/*     */   private static final String b = "EXCHANGE_REPORT_CACHE";
/*     */   private static XpListenersCenter.ReportListener c;
/*     */   private static List<XpListenersCenter.ReportListener> d;
/*     */   private Context e;
/*     */ 
/*     */   public XpReportClient(Context paramContext)
/*     */   {
/*  42 */     this.e = paramContext;
/*     */   }
/*     */ 
/*     */   public p.a send(o paramo)
/*     */   {
/*  49 */     if (c != null)
/*  50 */       c.onReportStart(((e)paramo).a);
/*  51 */     p.a locala = super.send(paramo);
/*  52 */     SharedPreferences localSharedPreferences = this.e.getSharedPreferences("EXCHANGE_REPORT_CACHE", 
/*  53 */       0);
/*     */ 
/*  55 */     synchronized (localSharedPreferences) {
/*  56 */       SharedPreferences.Editor localEditor = localSharedPreferences.edit();
/*  57 */       int i = 5;
/*  58 */       if (locala == p.a.a)
/*  59 */         a(localSharedPreferences, localEditor, i);
/*     */       else {
/*  61 */         a(localEditor, paramo);
/*     */       }
/*     */     }
/*     */ 
/*  65 */     if (c != null)
/*  66 */       c.onReportEnd(locala);
/*  67 */     return locala;
/*     */   }
/*     */ 
/*     */   private void a(SharedPreferences.Editor paramEditor, o paramo)
/*     */   {
/*  78 */     String str1 = paramo.b();
/*     */ 
/*  80 */     String str2 = str1.substring(paramo.d().length());
/*  81 */     paramEditor.putString(h.a(), str2);
/*  82 */     paramEditor.commit();
/*  83 */     Log.a(a, "add failed report : " + str2);
/*     */   }
/*     */ 
/*     */   private void a(SharedPreferences paramSharedPreferences, SharedPreferences.Editor paramEditor, int paramInt)
/*     */   {
/*  95 */     int i = 0;
/*  96 */     Map localMap = paramSharedPreferences.getAll();
/*  97 */     if (localMap.size() > 0) {
/*  98 */       Set localSet = localMap.keySet();
/*  99 */       for (String str1 : localSet) {
/* 100 */         i++; if (i >= paramInt)
/*     */           break;
/* 102 */         String str2 = (String)localMap.get(str1);
/* 103 */         HashMap localHashMap = new HashMap();
/* 104 */         String[] arrayOfString1 = str2.split("&");
/* 105 */         if (arrayOfString1.length < 1)
/*     */           break;
/* 107 */         for (localObject : arrayOfString1) {
/* 108 */           String[] arrayOfString3 = ((String)localObject).split("=");
/* 109 */           if (arrayOfString3.length == 2) {
/* 110 */             localHashMap.put(URLDecoder.decode(arrayOfString3[0]), 
/* 111 */               URLDecoder.decode(arrayOfString3[1]));
/*     */           }
/*     */         }
/* 114 */         Object localObject = super.send(new e(localHashMap));
/*     */ 
/* 116 */         if (localObject == p.a.a) {
/* 117 */           paramEditor.remove(str1);
/* 118 */           paramEditor.commit();
/* 119 */           Log.a(a, "clear failed report : " + str2);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void registerReportListener(XpListenersCenter.ReportListener paramReportListener)
/*     */   {
/* 134 */     if (d == null)
/* 135 */       d = new ArrayList();
/* 136 */     if (c == null) {
/* 137 */       c = new d();
/*     */     }
/*     */ 
/* 170 */     d.add(paramReportListener);
/*     */   }
/*     */ 
/*     */   public static void unregisterReportListener(XpListenersCenter.ReportListener paramReportListener)
/*     */   {
/* 180 */     if ((d != null) && (d.contains(paramReportListener))) {
/* 181 */       d.remove(paramReportListener);
/*     */     }
/*     */ 
/* 184 */     if (d.size() == 0) {
/* 185 */       d = null;
/* 186 */       c = null;
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.newxp.net.XpReportClient
 * JD-Core Version:    0.6.2
 */